package com.itheima.health.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.health.mapper.CheckItemMapper;
import com.itheima.health.pojo.CheckItem;
import com.itheima.health.pojo.CheckgroupAndCheckitem;
import com.itheima.health.service.CheckItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author kcs
 * @date 2021/11/23
 * @TIME:10:48
 */
@Service
public class CheckItemServiceImpl extends ServiceImpl<CheckItemMapper, CheckItem> implements CheckItemService {

    @Autowired
    private CheckItemMapper checkItemMapper;

    //查询所有检查项
    @Override
    public List<CheckItem> getAll() {
        return checkItemMapper.selectList(null);
    }

    //判断关系表中是否存在该检查项
    @Override
    public boolean findById(Integer id) {
        CheckgroupAndCheckitem checkgroupAndCheckitem = checkItemMapper.findById(id);
        if(checkgroupAndCheckitem != null){
            return true;
        }
        return false;
    }

    //在关系表中删除该检查项的所有数据
    @Override
    public void delete(Integer id) {
        checkItemMapper.delete(id);
    }
}
